package binary_tree.leetcode.easy;

/**
 * @author bruin_du
 * @description 对称的二叉树
 * @date 2022/5/23 18:21
 **/
public class Offer28_IsSymmetric {
    public boolean isSymmetric(TreeNode root) {
        if(root == null)
            return true;
        return recursion(root.left ,root.right);
    }

    private boolean recursion(TreeNode left, TreeNode right) {
        if(left == null && right == null)
            return true;
        if(left == null || right == null || left.val != right.val)
            return false;
        return recursion(left.left, right.right) && recursion(left.right, right.left);
    }
}
